package com.fhyc.service.impl;


import com.fhyc.dao.SoInAreaDao;
import com.fhyc.entity.SoInArea;
import com.fhyc.service.SoInArAreaService;
import com.fhyc.vo.AreaInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
@Slf4j
public class SoInArAreaServiceImpl implements SoInArAreaService {

    @Resource
    private SoInAreaDao soInAreaDao;

    @Override
    public List<AreaInfoVo> getAreaList() {
        List<AreaInfoVo> areaList = new ArrayList<>();
        List<SoInArea> soInAreas = soInAreaDao.selectList(null);
        for (SoInArea area : soInAreas) {
            //
            if (area.getParentId().equals("000000") || StringUtils.isEmpty(area.getParentId())) {
                AreaInfoVo vo = new AreaInfoVo();
                vo.setId(String.valueOf(area.getCtrlAreaId()));
                vo.setQxm(area.getCtrlAreaName());
                areaList.add(vo);
            }
        }
        AreaInfoVo vo = new AreaInfoVo();
        vo.setId("440300");
        vo.setQxm("深圳市");
        areaList.add(2,vo);
        return areaList;
    }

}
